package edu.spec.student.dao.impl;

import edu.spec.student.dao.iface.IMessageDao;
import edu.spec.student.model.Message;
import org.madgecko.basic.dao.BaseDao;
import org.madgecko.basic.model.Pager;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class MessageDao extends BaseDao<Message> implements IMessageDao  {

    @Override
    public void listLatest() {

    }

    @Override
    public List<Message> listByStudent(Integer studentId) {
        String hql = " from Message m where m.student.id=" + studentId + " and m.parent.id!=null order by m.messageDate";
        return this.list(hql);
    }

    @Override
    public Pager<Message> findByMessageDate() {
        String hql = " from Message m where m.parent.id!=null order by m.messageDate";
        return this.find(hql);
    }

}
